import React, { Component } from "react";
import { withRouter } from "next/router";
import Head from "next/head";
import Header from "../../components/header/index";
import Footer from "../../components/footer/index";
import BlogList from "../../components/blog-list";
import "./index.scss";
@withRouter
class Blogs extends Component {

	static getInitialProps = async (ctx, store) => {
		const { blogStore } = store;
		const result = await blogStore.getBlogList();
		return {
			houses: result.list || []
		};
	}

	constructor(props) {
		super(props);
		const { router, blogStore } = props;
		blogStore.changeType(router.pathname);
	}

	render() {
		const { houses, blogStore } = this.props;
		return (
			<React.Fragment>
				<Head>
					<title>后知后觉的博客</title>
					<meta name="keywords" content="justdodo,博客,房市" />
				</Head>
				<div className="main">
					<Header blogStore={blogStore}></Header>
					<div className="main-content">
						<BlogList data={houses}></BlogList >
					</div>
					<Footer></Footer>
				</div>
			</React.Fragment>
		);
	}
}

export default Blogs;